#include "BallRenderable.h"

namespace coolpool
{

	BallRenderable::BallRenderable(const math_tools::Vector3D & location, const math_tools::Matrix3D & orientation, double radius, GLuint texture)
	{
		location_ = location;
		matrix_tools::copyMatrix(orientation, orientation_);
		radius_ = radius;
		texture_ = texture;
	}

	BallRenderable::~BallRenderable()
	{

	}

	void BallRenderable::render() const
	{
		GLUquadric * cylinder_obj_ = gluNewQuadric();
		gluQuadricTexture(cylinder_obj_, GL_TRUE);

		glColor3d(1.0, 1.0, 1.0);
		glEnable(GL_TEXTURE_2D);
		glBindTexture(GL_TEXTURE_2D, texture_);
  
		glPushMatrix();
		glTranslated(location_.getX(), location_.getY(), location_.getZ());
		glMultMatrixd(orientation_);
		gluSphere(cylinder_obj_, radius_, 30, 30);
		glPopMatrix();
		gluDeleteQuadric(cylinder_obj_);
		glDisable(GL_TEXTURE_2D);
	}
}
